function getRandomQuote(){

    var ajax = newAjax();

    ajax.open("GET", "RandomServlet", true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax.send(null);
    ajax.onreadystatechange=function(){

        if(ajax.readyState == 4){

            if(ajax.status==200){

                document.getElementById("quote_div").innerHTML = ajax.responseText;
                
            }
        }
    }
}

function searchQuote(){

    var select = document.getElementById('searchSelect').selectedIndex;
    var person = document.getElementById('searchSelect').options[select].value;

    var ajax = newAjax();

    ajax.open("POST", "SearchServlet", true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax.send("person="+person);
    
    ajax.onreadystatechange=function(){

        if(ajax.readyState == 4){

            if(ajax.status==200){

                document.getElementById("search_div").innerHTML = ajax.responseText;

            }
        }
    }

}

function newAjax()
{
    var xmlhttp= false;

    try
    {
        // No IE
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");

    }
    catch(e)
    {

        try
        {
            // IE
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(E) {

            xmlhttp=false;

        }
    }

    if (!xmlhttp && typeof XMLHttpRequest!="undefined") {

        xmlhttp=new XMLHttpRequest();

    }

    return xmlhttp;
}

